package com.example.observe.events.core;

import java.lang.reflect.Method;

/**
 * 事件
 */
public class Event {

    // 事件源，事件是由谁发起的
    private Object source;
    // 事件触发，要通知谁
    private Object target;
    // 事件触发，要做什么动作，回调
    private Method callBack;
    // 事件名称，触发的是什么事件
    private String trigger;
    // 触发时间
    private Long time;

    public Event(Object target, Method callBack) {
        this.target = target;
        this.callBack = callBack;
    }

    public Object getSource() {
        return source;
    }

    public Event setSource(Object source) {
        this.source = source;
        return this;
    }

    public Object getTarget() {
        return target;
    }

    public Event setTarget(Object target) {
        this.target = target;
        return this;
    }

    public Method getCallBack() {
        return callBack;
    }

    public Event setCallBack(Method callBack) {
        this.callBack = callBack;
        return this;
    }

    public String getTrigger() {
        return trigger;
    }

    public Event setTrigger(String trigger) {
        this.trigger = trigger;
        return this;
    }

    public Long getTime() {
        return time;
    }

    public Event setTime(Long time) {
        this.time = time;
        return this;
    }

    @Override
    public String toString() {
        return "\nEvent{" +
                "\n\n\t\tsource=" + source +
                "\n\n\t\ttarget=" + target +
                "\n\n\t\tcallBack=" + callBack +
                "\n\n\t\ttrigger='" + trigger + "'" +
                "\n\n\t\ttime=" + time +
                "\n\n\t}\n\n";
    }

}
